home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_pyr_lightbox.cog < prev    next >
Text File  |  1999-11-15  |  12KB  |  486 lines

  1. # Jones 3D Cog Script
  2. #
  3. # pyr_lightbox.cog
  4. #    
  5. # Control lightboxes atop each pyramid
  6. #
  7. # [RKD]
  8. #
  9. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  10. # ========================================================================================
  11.  
  12. symbols
  13. message    startup
  14. message    activated
  15. message    arrived
  16. message    crossed
  17. message    user1
  18.  
  19. # lightbox elements
  20. thing    boxside0        
  21. thing    boxside1    nolink
  22. thing    boxside2    nolink
  23. thing    eyewall        nolink
  24. thing    paddle        nolink
  25. thing    flame        nolink
  26. thing    flame2        nolink
  27. thing    kindling    nolink
  28. thing    kindlingbox
  29. thing    bigbox        nolink
  30.  
  31. # cameras and camera gotos
  32. thing    cornercam        nolink
  33. thing    eyecam            nolink
  34. thing    cornercamgoto    nolink
  35. thing    eyecamgoto        nolink
  36.  
  37. # indy and the actors
  38. thing    player        local
  39. thing    indyactor0    nolink
  40. thing    indyactor1    nolink
  41. thing    indyactor2    nolink
  42.  
  43. # actor lookthings
  44. thing    indylook    nolink
  45.  
  46. # light channel and quadrants of room
  47. sector    glowsector    nolink
  48. sector    beamsector    nolink
  49. sector    farsector    nolink
  50. sector    midsector    nolink
  51. sector    holesector    nolink
  52.                         
  53. # surfaces
  54. surface    glowface    nolink
  55. surface    turnitoff
  56. surface    turniton
  57.  
  58. # indy's keyframes
  59. keyframe    lightwood=in_light_wood.key            local
  60. keyframe    handsOnHips=0in_stand4.key            local
  61. keyframe    handsToHips=0in_stand1_bd_4.key           local
  62.  
  63. # lightbox keyframes
  64. keyframe    paddlemove=pyr_padl_swch.key    local
  65. keyframe    lensfold=pyr_firebx_lens.key    local
  66. keyframe    sidefold=pyr_firebx_wall.key    local
  67.  
  68. # materials
  69. material    flamemat=gen_a4_oil_fire.mat    local
  70.  
  71. # indy's saylines
  72. sound    prismeye=pr12j07.wav    local
  73. sound    anothereye=pr12j08.wav    local
  74. sound    shaft=pr12j09.wav        local
  75. sound    prettydry=pr12j10.wav    local
  76. sound    firewood=pr12j11.wav    local
  77.  
  78. # varous sounds
  79. sound    paddlesnd=pyr_lightroom_paddle.wav    local
  80. sound    rising=pyr_lightbox_rise.wav        local
  81. sound    stopping=pyr_lightbox_stop.wav        local
  82. sound    closing=pyr_lightbox_panels.wav        local
  83. sound    lighttorch=gen_torchlitet_c.wav        local
  84. sound    burning=pyr_flame_loop.wav              local
  85.  
  86. # music
  87. sound    riseup1=mus_pyr_firebig.wav        local
  88. sound    riseup2=mus_pyr_firesmall.wav    local
  89.  
  90. # variables
  91. vector    pyrlight0    local
  92. vector    pyrlight1    local
  93. vector    pyrlight2    local
  94. vector    pyrlight3    local
  95. vector    pyrlight4    local
  96. vector    torchlight    local
  97.  
  98. int        pyrnum=0
  99. int        actornum=0        local
  100. int        locked=0        local
  101. int        curmusic=0        local
  102. int        curvoice=0        local
  103. int        curactor=0        local
  104. int        curanim=0        local
  105. int        cursound=0        local
  106. int        flamesound=0    local
  107.  
  108. # subroutines
  109. flex    startscene=0.0        local
  110. flex    fixcams=0.0            local
  111. flex    lightkindling=0.0    local
  112. flex    boxrise=0.0            local
  113. end
  114.  
  115.  
  116. code
  117. startup:
  118.     player = GetLocalPlayerThing();
  119.     
  120.     # establish lighting values for each pyramid
  121.     pyrlight0 = VectorSet(0, 0, 0);
  122.     pyrlight1 = VectorSet(0.6, 0, 1.5);
  123.     pyrlight2 = VectorSet(0, 1.5, 0);
  124.     pyrlight3 = VectorSet(1.5, 0, 0);
  125.     pyrlight4 = VectorSet(1.5, 1.5, 0);
  126.     torchlight = VectorSet(0.87, 0.55, 0.06);
  127.     
  128.     # set kindling to no light, turn flame off
  129.     SetThingLight(kindling, pyrlight0, 0.001, 0.01);
  130.     SetThingFlags(flame, 0x10);
  131.     SetThingFlags(flame2, 0x10);
  132.  
  133.     # start big flame animating
  134.     MaterialAnim(flamemat, 10, 1);
  135.  
  136.     # turn off collision on lightbox parts
  137.     SetCollideType(boxside0, 0);
  138.     SetCollideType(boxside1, 0);
  139.     SetCollideType(boxside2, 0);
  140.     SetCollideType(eyewall, 0);
  141.     SetCollideType(bigbox, 0);
  142.     
  143.     #seal off sight path
  144.     SetSectorAdjoins(glowsector, 0);
  145.  
  146.     # global4 represents number of lightboxes that have risen
  147.     global4 = 0;
  148.  
  149.     return;
  150.  
  151. activated:
  152. # ---> kindlingbox (easier to activate than kindling)
  153.     
  154.     # if kindlingbox is not what's activated, or is not there(visible), or is already lit(locked), return
  155.     if (locked) return;
  156.     if (GetSenderRef() != kindlingbox)    return;
  157.     if (GetThingFlags(kindling) & 0x10) return;
  158.  
  159.     # if player is somehow standing in the entry sector, exit
  160.     if (GetThingSector(player) == holesector) return;
  161.     
  162.     #if player isn't carrying lighter (and not in Marcus) give a hint
  163.     if ((GetCurWeapon(player) != 13) && (!InEditor()))
  164.     {
  165.         # freeze player, start scene
  166.         if (MakeMeStop() == -1) return;
  167.         DeselectWeaponWait(player);
  168.         
  169.         StartCutscene(1);
  170.         
  171.         SetExtCamOffset('0.07 -0.13 0.13');
  172.         sleep(.5);
  173.  
  174.         if (global4 == 0)
  175.         {
  176.             curvoice = PlayVoice(player, prettydry, 1, 1);
  177.         }
  178.         else
  179.         {
  180.             curvoice = PlayVoice(player, firewood, 1, 1);
  181.         }
  182.  
  183.         sleep(.5);
  184.         RestoreExtCam();
  185.         ClearActorFlags(player, 0x200000);
  186.         EndCutscene();
  187.  
  188.         return;
  189.     }
  190.  
  191.     if (MakeMeStop() == -1) return;
  192.     
  193.     locked = 1;
  194.     
  195.     # increment global4 to vary Indy's reaction each time
  196.     global4 = global4 + 1;
  197.     
  198.     # figure out which indyactor to use
  199.     if (GetThingSector(player) == beamsector) actornum = 0;
  200.     if (GetThingSector(player) == midsector) actornum = 1;
  201.     if (GetThingSector(player) == farsector) actornum = 2;
  202.     curactor = indyactor0[actornum];
  203.  
  204.     call startscene;
  205.     call lightkindling;
  206.     sleep(2);
  207.     call boxrise;
  208.     
  209.     # make indy put his hands down if they aren't already
  210.     StopKey(curactor, curanim, .5);
  211.     
  212.     WaitForSound(curmusic);
  213.  
  214.     call fixcams;
  215.  
  216.     TeleportThing(player, curactor);
  217.     SetThingFlags(curactor, 0x80000);
  218.     ClearThingFlags(player, 0x80000);
  219.     ClearActorFlags(player, 0x200000);
  220.  
  221.     # Establish a camera position near Indy and prep follow-cam...            
  222.     SetCameraPosition(1, VectorAdd(VectorTransformToOrient(player, '0.25 -0.1 0.0'), GetThingPos(player)));    
  223.     SetCurrentCamera(1);
  224.  
  225.     # post cutscene, draw glowface again
  226.     SetFaceGeoMode(glowface, 4);
  227.     
  228.     # Bring bigbox into play (handles wierdo collision for lightbox)
  229.     SetCollideType(bigbox, 3);
  230.     
  231.     EndCutscene();
  232.     return;
  233.     
  234. startscene:
  235.     call fixcams;    
  236.  
  237.     StartCutscene(1);
  238.     CopyPlayerHolsters(player, curactor);
  239.     SetActorFlags(player, 0x200000);
  240.     TeleportThing(player, curactor);
  241.  
  242.     # change to cornercam
  243.     SetCameraFocus(2, cornercam);
  244.     SetCameraSecondaryFocus(2, flame);
  245.     SetCurrentCamera(2);
  246.     SetCameraFOV(90, 0, 0);
  247.     return;
  248.         
  249. lightkindling:
  250.     # light kindling, make flame visible
  251.     curanim = PlayKey(player, lightwood, 2, 0x14, 0);
  252.     Sleep(.5);
  253.     
  254.     # make flames visible, lit up, noisy, and slowly rotating
  255.     SetThingLight(flame, torchlight, 0.001, 0.2);
  256.     SetThingLight(kindling, torchlight, 0.38, 0.01);
  257.     ClearThingFlags(flame, 0x10);
  258.     Rotate(flame, 3600, 1, 150);
  259.     PlaySoundThing(lighttorch, kindling, 1, 3, 10, 0);
  260.     sleep(.1);
  261.     SetThingLight(flame2, torchlight, 0.001, 0.4);
  262.     ClearThingFlags(flame2, 0x10);
  263.     Rotate(flame2, 3600, 1, 75);
  264.     flamesound = PlaySoundThing(burning, kindling, 1, 3, 10, 1);
  265.     StopKey(player, curanim, 1);
  266.  
  267.     # light up the lightbox parts
  268.     SetThingLight(boxside0, torchlight, .001, .5);
  269.     SetThingLight(boxside1, torchlight, .001, .5);
  270.     SetThingLight(boxside2, torchlight, .001, .5);
  271.     SetThingLight(eyewall, torchlight, .001, .5);
  272.  
  273.     # play different music depending on the number of lightboxes raised
  274.     if (global4 == 1)
  275.     {
  276.         curmusic = PlaySoundLocal(riseup1, 1, 0, 0, 0);
  277.     }
  278.     
  279.     Sleep(.5);
  280.     
  281.     # change to actor for reaction
  282.     DeselectWeaponWait(player);
  283.     TeleportThing(curactor, player);
  284.     CopyPlayerHolsters(player, curactor);
  285.     SetThingFlags(player, 0x80000);
  286.     ClearThingFlags(curactor,0x80000);
  287.     
  288.     #make indy look at the flame    
  289.     AIEnableHeadTracking(curactor, flame);
  290.     AIEnableBodyTracking(curactor, flame);
  291.     
  292.     Sleep(.5);
  293.     
  294.     # change cameras
  295.     SetCameraPosInterp(2, 1);
  296.     SetCameraInterpSpeed(2, 4);
  297.     SetCameraFocus(2, cornercamgoto);
  298.     SetCameraFOV(100, 1, 4);
  299.     
  300.     # play paddle animation
  301.     PlayKey(paddle, paddlemove, 4, 0x4, 0);
  302.     PlaySoundThing(paddlesnd, paddle, 1, 3, 10, 0);
  303.     
  304.     sleep(.75);
  305.  
  306.     # if this is the beam sector, keep Indy from moonwalking
  307.     if (GetThingSector(player) == beamsector)
  308.     {
  309.         AIEnableBodyTracking(curactor, indylook);
  310.     }
  311.     
  312.     AISetMoveFrame(curactor, 1);
  313.  
  314.     return;
  315.  
  316. boxrise:
  317.     # restore collision to lightbox parts
  318.     SetCollideType(boxside0, 3);
  319.     SetCollideType(boxside1, 3);
  320.     SetCollideType(boxside2, 3);
  321.     SetCollideType(eyewall, 3);
  322.  
  323.     # make box parts move up
  324.     ChangeSoundVol(flamesound, .1, 3.5);
  325.     AttachThingToThing(indylook, eyewall);
  326.     MoveToFrame(eyewall, 1, 1);
  327.     MoveToFrame(boxside0, 1, 1);
  328.     MoveToFrame(boxside1, 1, 1);
  329.     MoveToFrame(boxside2, 1, 1);
  330.     cursound = PlaySoundThing(rising, eyewall, 1, 3, 10, 0);
  331.         
  332.     # create low-level tint on box parts and make kindling light the room
  333.     SetThingLight(eyewall, pyrlight0[pyrnum], 0.001, 6);
  334.     SetThingLight(boxside0, pyrlight0[pyrnum], 0.001, 6);
  335.     SetThingLight(boxside1, pyrlight0[pyrnum], 0.001, 6);
  336.     SetThingLight(boxside2, pyrlight0[pyrnum], 0.001, 6);
  337.     SetThingLight(kindling, pyrlight0[pyrnum], 0.38, 6);
  338.  
  339.     sleep(.4);
  340.  
  341.     if (global4 > 2)
  342.     {
  343.         curanim = PlayKey(curactor, handstohips, 4, 0x12, 1);
  344.         curanim = PlayKey(curactor, handsonhips, 4, 0x14, 0);
  345.     }
  346.  
  347.     #make indy look at the box
  348.     SetThingMaxHeadVel(curactor, 225);    
  349.     AIEnableHeadTracking(curactor, indylook);
  350.     AIEnableBodyTracking(curactor, indylook);
  351.  
  352.     Sleep(1);
  353.  
  354.     # if not the first time, start shorter music here instead
  355.     if (global4 != 1)
  356.     {
  357.         curmusic = PlaySoundLocal(riseup2, 1, 0, 0, 0);
  358.     }
  359.  
  360.     if (global4 == 1)
  361.     {
  362.         Sleep(.5);
  363.         ChangeSoundVol(cursound, 0.2, 0.3);
  364.         ChangeSoundVol(curmusic, 0.2, 0.3);
  365.         PlaySoundLocal(prismeye, 1, 0, 0, 1);
  366.         ChangeSoundVol(curmusic, 1, 0.4);
  367.         ChangeSoundVol(cursound, 1, 0.4);
  368.     }
  369.     else if (global4 == 2)
  370.     {
  371.         Sleep(.1);
  372.         ChangeSoundVol(cursound, 0.2, 0.3);
  373.         ChangeSoundVol(curmusic, 0.2, 0.3);
  374.         PlaySoundLocal(anothereye, 1, 0, 0, 1);
  375.         ChangeSoundVol(cursound, 1, 0.4);
  376.         ChangeSoundVol(curmusic, 1, 0.4);
  377.     }
  378.     
  379.     return;
  380.  
  381. arrived:
  382. # ---> BoxSide0
  383.  
  384.     cursound = PlaySoundThing(stopping, eyewall, 1, 3, 10, 0);
  385.     
  386.     #fold box after it rises
  387.     sleep(.5);
  388.     cursound = PlaySoundThing(closing, eyewall, 1, 3, 10, 0);
  389.     PlayKey(eyewall, lensfold, 4, 0x14, 0);
  390.     PlayKey(boxside0, sidefold, 4, 0x14, 0);
  391.     PlayKey(boxside1, sidefold, 4, 0x14, 0);
  392.     PlayKey(boxside2, sidefold, 4, 0x14, 0);
  393.         
  394.     SetFaceGeoMode(glowface, 0);
  395.     
  396.     SetCameraInterpSpeed(2, 4);
  397.     SetCameraFocus(2, eyecam);
  398.     SetCameraFOV(90, 1, 4);
  399.  
  400.     sleep(4);
  401.     
  402.     # pullback speed is different depending on length of music
  403.     if (global4 == 1)
  404.     {
  405.         SetCameraInterpSpeed(2, 7);
  406.     }
  407.     else
  408.     {
  409.         SetCameraInterpSpeed(2, 5.25);
  410.     }
  411.  
  412.     SetCameraFocus(2, eyecamgoto);
  413.  
  414.     if (global4 == 2)
  415.     {
  416.         ChangeSoundVol(cursound, 0.2, 0.3);
  417.         ChangeSoundVol(curmusic, 0.2, 0.3);
  418.         curvoice = PlaySoundLocal(shaft, 1, 0, 0, 1);
  419.         ChangeSoundVol(curmusic, 1, 0.4);
  420.         ChangeSoundVol(cursound, 1, 0.4);
  421.     }
  422.     
  423.     return;
  424.  
  425. user1:
  426. # ---> monojackal cog
  427.     
  428.     # set flame invisible and stop rotation
  429.     SetThingFlags(flame, 0x10);
  430.     SetThingLight(flame, '0 0 0', 0.0001, .01);
  431.     StopThing(flame);
  432.  
  433.     # destroy flame2 and kindling (which removes sound and light from both)
  434.     DestroyThing(flame2);
  435.     StopSound(flamesound, 1);
  436.     DestroyThing(kindling);
  437.     
  438.     # remove light from lightbox walls
  439.     SetThingLight(eyewall, '0 0 0', 0.001, .01);
  440.     SetThingLight(boxside0, '0 0 0', 0.001, .01);
  441.     SetThingLight(boxside1, '0 0 0', 0.001, .01);
  442.     SetThingLight(boxside2, '0 0 0', 0.001, .01);
  443.  
  444.     return;
  445.  
  446. crossed:
  447. # ---> TurnItOn and TurnItOff adjoins
  448.     
  449.     if (GetSenderRef() == turniton)
  450.     {
  451.         # make glowing face transparent, add visibility to light channel
  452.         SetFaceGeoMode(glowface, 0);
  453.         SetSectorAdjoins(glowsector, 1);
  454.         
  455.         # if puzzle is sprung, put light back on kindling
  456.         if (!GetThingFlags(flame) & 0x10)
  457.         {
  458.             SetThingLight(kindling, pyrlight0[pyrnum], 0.38, .1);
  459.         }
  460.     }
  461.     
  462.     if (GetSenderRef() == turnitoff)
  463.     {
  464.         # take light off kindling (if flame visible), remove visibility from light channel
  465.         if (!GetThingFlags(flame) & 0x10)
  466.         {
  467.             SetThingLight(kindling, pyrlight0, 0.38, .1);
  468.         }
  469.         
  470.         SetSectorAdjoins(glowsector, 0);
  471.         SetFaceGeoMode(glowface, 4);
  472.     }
  473.     return;
  474.  
  475. fixcams:
  476.     # reset camera settings
  477.     ResetCameraFOV(0, 0);
  478.     SetCameraPosInterp(2, 0);
  479.     SetCameraLookInterp(2, 0);
  480.     SetCameraPosInterp(1, 0);
  481.     SetCameraLookInterp(1, 0);
  482.     RestoreExtCam();
  483.     return;
  484.  
  485. end
  486.